package com.sgu6.sgu6_machine.util;

import android.graphics.BitmapFactory;

import com.sgu6.sgu6_machine.common.Constant;

import java.io.File;

public class FileUtils {

    public static File getLocalImageByName(String imageName) {
        File file = new File(Constant.FILE_ROOT_PATH + "/sgu6/images/", imageName);
        return file;
    }

    /**
     * 判断是否为完整图片
     *
     * @param fileName
     * @return
     */
    public static boolean checkFileByName(String fileName) {
        String filePath = Constant.FILE_ROOT_PATH + "/sgu6/images/" + fileName;
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, options);
        if (options.outWidth == -1) {
            return false;
        }
        return true;
    }
}
